//
//  DBJIllCaseTagViewController.m
//  DBJ
//
//  Created by Captain_czq on 16/11/14.
//  Copyright © 2016年 itcast. All rights reserved.
//

#import "DBJIllCaseTagViewController.h"
#import "DBJIllCaseTagModel.h"
#import "DBJIllCaseTagCell.h"
#define CellID @"tagCell"
@interface DBJIllCaseTagViewController ()
/* 选中的标签数组 */
@property(nonatomic,strong)NSMutableArray *tagM;
/* 模型数组 */
@property(nonatomic,strong)NSArray * modelPlist;
@end

@implementation DBJIllCaseTagViewController

- (void)viewDidLoad {
    [super viewDidLoad];
//    [super dbjSetupSubviews];
//    self.view.backgroundColor=[UIColor whiteColor];
//    //实例化tagM数组
//    self.tagM=[NSMutableArray array];
//    self.modelPlist=[DBJIllCaseTagModel getmodelPlist];
////    self.tableView.rowHeight=60;
//    //注册cell
//    [self.tableView registerClass:[DBJIllCaseTagCell class] forCellReuseIdentifier:CellID];
//    [self.tableView reloadData];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/* 重写dbjsubViews方法*/
-(void)dbjSetupSubviews{

    [super dbjSetupSubviews];
    self.view.backgroundColor=[UIColor whiteColor];
    //实例化tagM数组
    self.tagM=[NSMutableArray array];
    self.modelPlist=[DBJIllCaseTagModel getmodelPlist];
    //    self.tableView.rowHeight=60;
    //注册cell
    [self.tableView registerClass:[DBJIllCaseTagCell class] forCellReuseIdentifier:CellID];
    [self.tableView reloadData];
    self.tableView.separatorStyle= UITableViewCellSeparatorStyleSingleLine;
    
}

#pragma mark -设置navItem
-(void)dbjSetupNavigationItems{
    self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc]initWithTitle:@"确定" style:UIBarButtonItemStylePlain target:self action:@selector(clickRightItem:)];
    
}
/* 右边item的方法 */
-(void)clickRightItem:(UIBarButtonItem *)sender{
    if([self.delegate respondsToSelector:@selector(sendTagWithCOntroller:tagList:)]){
        [self.delegate sendTagWithCOntroller:self tagList:self.tagM.copy];
    }
    [self.navigationController popViewControllerAnimated:YES];
}


#pragma mark -实现添加标签界面代理Tab方法
/* 选择行的的代理方法 */
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    DBJIllCaseTagCell *cell=[tableView cellForRowAtIndexPath:indexPath];
    cell.selceted=NO;
    
    //把选中的数据添加到标签数组中
    DBJIllCaseTagModel *mdoel=self.modelPlist[indexPath.row];
    [self.tagM addObject:mdoel.name];
}



#pragma mark -实现添加标签界面的数据源方法
/* 实现返回单元格个数的方法 */
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.modelPlist.count;
}
/* 实现返回单元格的方法 */
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    //获取cell
    DBJIllCaseTagCell *cell=[tableView dequeueReusableCellWithIdentifier:CellID forIndexPath:indexPath];
    cell.model=self.modelPlist[indexPath.row];
    
    return cell;
}


@end
